﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DZPK
{
    public class Debugger_ListView
    {
        private Form1 notifyWnd = null;

        public Debugger_ListView(Form1 wnd)
        {
            notifyWnd = wnd;
        }

        public void ProcessLoginSuccess(string roomName, int smallBlind, Int64 buyMinChips, Int64 buyMaxChips, Int64 playerCoins, int chipinTime)
        {
            string strMsg = "Server LoginSuccess Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Room Name : {0}, SmallBlind : {1}, MinChips : {2}, MaxChips : {3}, PlayerCoins : {4}", roomName, smallBlind, buyMinChips, buyMaxChips, playerCoins);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessBindSuccessResponse(string roomName, int smallBlind, Int64 buyMinChips, Int64 buyMaxChips, int seatID, Int64 playerCoins, int card1, int card2)
        {
            string strMsg = "Server BindSuccess Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Room Name : {1}, SeatID : {0}, SmallBlind : {2}, MinChips : {3}, MaxChips : {4}, PlayerCoins : {5}", roomName, seatID, smallBlind, buyMinChips, buyMaxChips, playerCoins);
            notifyWnd.AddMessage(strMsg);

            Card usrCard1 = new Card(card1);
            Card usrCard2 = new Card(card2);
            strMsg = string.Format("Player Card 1 : Color {0} Value {1}, Card 2 : Color {2} Value {3}", usrCard1.Color, usrCard1.Value, usrCard2.Color, usrCard2.Value);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessRoomInfoResponse(int gameState, int maxPlayCount, int gameBid, int dealer, int size, List<int> cardList)
        {
            string strMsg = "Server RoomInfo Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Game State : {0}, Current Player Count : {1},  Max Player Count : {2}", gameState, maxPlayCount, size);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessPlayerInfoResponse(int seatID, int mid, Int64 usrCoins, string usrname, Int64 bureauMoney, Int64 seatChips, int isPlay, int chipinType)
        {
            string strMsg = "Server RoomInfo Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Seat ID : {0}, Mid : {1}, UserName : {2}", seatID, mid, usrname);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessUserActionResponse(int seatID, int cardOption, Int64 seatMoney, Int64 seatChips, Int64 usrCoins)
        {
            string strMsg = "User Action Response";
            notifyWnd.AddMessage(strMsg);

            string option = CommandHelper.IntOptionToString(cardOption);
            strMsg = string.Format("Seat ID : {0}, Action : {1}, Seat Money : {2}, Seat Chips : {3}, User Coins : {4}", seatID, option, seatMoney, seatChips, usrCoins);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessUserSitResponse(int seatID, int mid, Int64 usrCoin, string usrname, Int64 seatMoney)
        {
            string strMsg = "User Sit Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Seat ID : {0}, Mid : {1}, UserName : {2}", seatID, mid, usrname);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessChipinPromptResponse(int seatID, Int64 needCall, Int64 needRaise, Int64 maxRaise)
        {
            string strMsg = "Prompt User Chipin Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Seat ID : {0}, Need Call : {1}, Need Raise : {2}, Max Raise : {3}", seatID, needCall, needRaise, maxRaise);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessUserStandResponse(int seatID, string usrname, Int64 usrCoins)
        {
            string strMsg = "User Stand Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Seat ID : {0}, UserName : {1}", seatID, usrname);
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessSysMsgResponse(string sysMsg)
        {
            string strMsg = "System Message Response";
            notifyWnd.AddMessage(strMsg);

            notifyWnd.AddMessage(sysMsg);
        }

        public void ProcessDealFolpResponse(int card1, int card2, int card3)
        {
            string strMsg = "Deal Folp Response";
            notifyWnd.AddMessage(strMsg);

            Card c1 = new Card(card1);
            Card c2 = new Card(card2);
            Card c3 = new Card(card3);

            strMsg = string.Format("Pulic Card : Card 1 : {0}, Card 2 : {1}, Card 3 : {2}", c1.ToString(), c2.ToString(), c3.ToString());
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessDealPrefLop(int seatID, int card1, int card2)
        {
            string strMsg = "Deal Pre Folp Response";
            notifyWnd.AddMessage(strMsg);

            Card c1 = new Card(card1);
            Card c2 = new Card(card2);

            strMsg = string.Format("My Card : Card 1 : {0}, Card 2 : {1}", c1.ToString(), c2.ToString());
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessDealTurn(int cardTurn)
        {
            string strMsg = "Deal Turn Response";
            notifyWnd.AddMessage(strMsg);

            Card cTurn = new Card(cardTurn);

            strMsg = string.Format("Turn Card : Card Turn : {0}", cTurn.ToString());
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessLoginFailedResponse(int reasonID)
        {
            string strMsg = "Login Failed Response";
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessUserLogOutResponse(int mid, string usrname)
        {
            string strMsg = "Logout Success Response";
            notifyWnd.AddMessage(strMsg);
        }
        public void ProcessLoginOutSuccessResponse()
        {
            string strMsg = "Log in out Success Response";
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessConnectFailedResponse()
        {
            string strMsg = "Connect Fail Response";
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessSitFailedResponse(int failreasonID)
        {
            string strMsg = "Sit Fail Response";
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessUserNoticeAllResponse(int seatID, int noticeCmd, string noticeContent)
        {

        }

        public void ProcessFinalRoundResponse()
        {

        }

        public void ProcessKickUserResponse(int mid, int seatID)
        {

        }

        public void ProcessSitSuccessResponse(int seatID, string usrname, Int64 seatMoney)
        {
            string strMsg = "Sit Success Response";
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessDealRiverResponse(int cardRiver)
        {
            string strMsg = "Deal River Response";
            notifyWnd.AddMessage(strMsg);

            Card cRiver = new Card(cardRiver);

            strMsg = string.Format("Turn Card : Card Turn : {0}", cRiver.ToString());
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessFinalGameResponse(List<GameResult> result)
        {
            string strMsg = "Final Game Response";
            notifyWnd.AddMessage(strMsg);

            for (int i = 0; i < result.Count; i++)
            {
                GameResult oWin = result[i];

                strMsg = string.Format("Winner Mid : {0}, Win Money : {1}", oWin.winMid, oWin.winMoney);
                notifyWnd.AddMessage(strMsg);
            }
        }

        public void ProcessUserChipInErrResponse()
        {
            string strMsg = "ChipIn Error Response";
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessUserUpdataExpResponse(string expUpdateString)
        {
            string strMsg = "User Exp Update Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = expUpdateString;
            notifyWnd.AddMessage(strMsg);
        }

        public void ProcessGameStartResponse(int dealer, List<StartGamePlayerResponse> startPlayerList)
        {
            string strMsg = "Game Start Response";
            notifyWnd.AddMessage(strMsg);

            strMsg = string.Format("Dealer : {0}", dealer);
            notifyWnd.AddMessage(strMsg);

            for (int i = 0; i < startPlayerList.Count; i++)
            {
                StartGamePlayerResponse oStart = startPlayerList[i];

                strMsg = string.Format("SeatID : {0}, SeatMoney : {1], SeatChips : {2}, UserCoins : {3}", oStart.seatID, oStart.seatMoney, oStart.seatChips, oStart.usrCoins);
                notifyWnd.AddMessage(strMsg);
            }
        }

        public void ShowPreflopResponse(List<UserHandCardResponse> usrHandCardList)
        {

        }
    }
}
